/**
 * MealProduct 业务逻辑实现类
 * @author yanwl
 * @date 2014-08-23
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.MealProduct;
import com.chnbst.bstyun.model.vo.MealProductVo;
import com.chnbst.bstyun.service.MealProductService;

@Transactional
@Service
public class MealProductServiceImpl extends BaseService implements MealProductService {
	
	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(MealProductServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.MealProductMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean deleteMealProduct(Integer mealProductId) {
		return DaoHelper.delete(nameSpace, "deleteMealProduct", mealProductId);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertMealProduct(MealProduct mealProduct) {
		return DaoHelper.insert(nameSpace, "insertMealProduct", mealProduct);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateMealProduct(MealProduct mealProduct) {
		return DaoHelper.update(nameSpace, "updateMealProduct", mealProduct);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public MealProduct selectMealProductByMealProductId(Integer mealProductId) {
		return (MealProduct)DaoHelper.query(nameSpace, "selectMealProductByMealProductId", mealProductId);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<MealProductVo> selectMealProductVos(Map<String, Object> map) {
		return (List<MealProductVo>)DaoHelper.list(nameSpace, "selectMealProductVos", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectMealProductCount(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectMealProductCount", map);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<MealProduct> selectMealProductsByMealId(Integer mealId) {
		return (List<MealProduct>) DaoHelper.list(nameSpace, "selectMealProductsByMealId", mealId);
	}
	
	
}
